}
pub struct PackageRegistry<'a> {
- sources: SourceMap,
+ sources: SourceMap<'a>,
overrides: Vec<SourceId>,
config: &'a mut Config<'a>
}
Ok(ret)
}
- pub fn move_sources(self) -> SourceMap {
+ pub fn move_sources(self) -> SourceMap<'a> {
self.sources
}
}
}
-struct Context<'a, R> {
+struct Context<'a, R:'a> {
registry: &'a mut R,
resolve: Resolve,
pub tty: bool
}
-enum AdequateTerminal {
- NoColor(Box<Writer>),
- Color(Box<Terminal<Box<Writer>>>)
+enum AdequateTerminal<'a> {
+ NoColor(Box<Writer+'a>),
+ Color(Box<Terminal<Box<Writer+'a>>+'a>)
}
-pub struct Shell {
- terminal: AdequateTerminal,
+pub struct Shell<'a> {
+ terminal: AdequateTerminal<'a>,
config: ShellConfig
}
-pub struct MultiShell {
- out: Shell,
- err: Shell,
+pub struct MultiShell<'a> {
+ out: Shell<'a>,
+ err: Shell<'a>,
verbose: bool
}
pub type Callback<'a> = |&mut MultiShell|:'a -> IoResult<()>;
-impl MultiShell {
- pub fn new(out: Shell, err: Shell, verbose: bool) -> MultiShell {
+impl<'a> MultiShell<'a> {
+ pub fn new(out: Shell<'a>, err: Shell<'a>, verbose: bool) -> MultiShell<'a> {
MultiShell { out: out, err: err, verbose: verbose }
}
- pub fn out(&mut self) -> &mut Shell {
+ pub fn out(&mut self) -> &mut Shell<'a> {
&mut self.out
}
- pub fn err(&mut self) -> &mut Shell {
+ pub fn err(&mut self) -> &mut Shell<'a> {
&mut self.err
}
}
}
-pub type ShellCallback<'a> = |&mut Shell|:'a -> IoResult<()>;
+pub type ShellCallback<'a> = |&mut Shell<'a>|:'a -> IoResult<()>;
-impl Shell {
- pub fn create(out: Box<Writer>, config: ShellConfig) -> Shell {
+impl<'a> Shell<'a> {
+ pub fn create(out: Box<Writer+'a>, config: ShellConfig) -> Shell<'a> {
if config.tty && config.color {
- let term: Option<term::TerminfoTerminal<Box<Writer>>> = Terminal::new(out);
+ let term: Option<term::TerminfoTerminal<Box<Writer+'a>>> = Terminal::new(out);
term.map(|t| Shell {
- terminal: Color(box t as Box<Terminal<Box<Writer>>>),
+ terminal: Color(box t as Box<Terminal<Box<Writer+'a>>>),
config: config
}).unwrap_or_else(|| {
- Shell { terminal: NoColor(box stderr() as Box<Writer>), config: config }
+ Shell { terminal: NoColor(box stderr() as Box<Writer+'a>), config: config }
})
} else {
Shell { terminal: NoColor(out), config: config }
}
}
-impl Terminal<Box<Writer>> for Shell {
- fn new(out: Box<Writer>) -> Option<Shell> {
+impl<'a> Terminal<Box<Writer+'a>> for Shell<'a> {
+ fn new(out: Box<Writer+'a>) -> Option<Shell<'a>> {
Some(Shell {
terminal: NoColor(out),
config: ShellConfig {
}
}
- fn unwrap(self) -> Box<Writer> {
+ fn unwrap(self) -> Box<Writer+'a> {
fail!("Can't unwrap a Shell");
}
- fn get_ref<'a>(&'a self) -> &'a Box<Writer> {
+ fn get_ref<'b>(&'b self) -> &'b Box<Writer+'a> {
match self.terminal {
Color(ref c) => c.get_ref(),
NoColor(ref w) => w
}
}
- fn get_mut<'a>(&'a mut self) -> &'a mut Box<Writer> {
+ fn get_mut<'b>(&'b mut self) -> &'b mut Box<Writer+'a> {
match self.terminal {
Color(ref mut c) => c.get_mut(),
NoColor(ref mut w) => w
}
}
-impl Writer for Shell {
+impl<'a> Writer for Shell<'a> {
fn write(&mut self, buf: &[u8]) -> IoResult<()> {
match self.terminal {
Color(ref mut c) => c.write(buf),
}
}
- pub fn load(&self, config: &mut Config) -> Box<Source> {
+ pub fn load<'a>(&self, config: &'a mut Config) -> Box<Source+'a> {
log!(5, "loading SourceId; {}", self);
match self.kind {
- GitKind(..) => box GitSource::new(self, config) as Box<Source>,
+ GitKind(..) => box GitSource::new(self, config) as Box<Source+'a>,
PathKind => {
let path = match self.url.to_file_path() {
Ok(p) => p,
};
box PathSource::new(&path, self) as Box<Source>
},
- RegistryKind => box DummyRegistrySource::new(self) as Box<Source>,
+ RegistryKind => box DummyRegistrySource::new(self) as Box<Source+'a>,
}
}
}
}
-pub struct SourceMap {
- map: HashMap<SourceId, Box<Source>>
+pub struct SourceMap<'a> {
+ map: HashMap<SourceId, Box<Source+'a>>
}
-pub type Sources<'a> = Values<'a, SourceId, Box<Source>>;
-pub type SourcesMut<'a> = iter::Map<'static, (&'a SourceId, &'a mut Box<Source>),
- &'a mut Source,
- MutEntries<'a, SourceId, Box<Source>>>;
+pub type Sources<'a> = Values<'a, SourceId, Box<Source+'a>>;
+pub type SourcesMut<'a> = iter::Map<'static, (&'a SourceId, &'a mut Box<Source+'a>),
+ &'a mut Source+'a,
+ MutEntries<'a, SourceId, Box<Source+'a>>>;
-impl SourceMap {
- pub fn new() -> SourceMap {
+impl<'a> SourceMap<'a> {
+ pub fn new() -> SourceMap<'a> {
SourceMap {
map: HashMap::new()
}
self.map.contains_key(id)
}
- pub fn get(&self, id: &SourceId) -> Option<&Source> {
+ pub fn get(&self, id: &SourceId) -> Option<&Source+'a> {
let source = self.map.find(id);
source.map(|s| {
- let s: &Source = *s;
+ let s: &Source+'a = *s;
s
})
}
- pub fn get_mut(&mut self, id: &SourceId) -> Option<&mut Source> {
+ pub fn get_mut(&mut self, id: &SourceId) -> Option<&mut Source+'a> {
self.map.find_mut(id).map(|s| {
- let s: &mut Source = *s;
+ let s: &mut Source+'a = *s;
s
})
}
- pub fn get_by_package_id(&self, pkg_id: &PackageId) -> Option<&Source> {
+ pub fn get_by_package_id(&self, pkg_id: &PackageId) -> Option<&Source+'a> {
self.get(pkg_id.get_source_id())
}
- pub fn insert(&mut self, id: &SourceId, source: Box<Source>) {
+ pub fn insert(&mut self, id: &SourceId, source: Box<Source+'a>) {
self.map.insert(id.clone(), source);
}
self.map.len()
}
- pub fn sources(&self) -> Sources {
+ pub fn sources(&'a self) -> Sources<'a> {
self.map.values()
}
- pub fn sources_mut(&mut self) -> SourcesMut {
- self.map.mut_iter().map(|(_, v)| { let s: &mut Source = *v; s })
+ pub fn sources_mut(&'a mut self) -> SourcesMut<'a> {
+ self.map.mut_iter().map(|(_, v)| { let s: &mut Source+'a = *v; s })
}
}
-pub struct SourceSet {
- sources: Vec<Box<Source>>
+pub struct SourceSet<'a> {
+ sources: Vec<Box<Source+'a>>
}
-impl SourceSet {
- pub fn new(sources: Vec<Box<Source>>) -> SourceSet {
+impl<'a> SourceSet<'a> {
+ pub fn new(sources: Vec<Box<Source+'a>>) -> SourceSet<'a> {
SourceSet { sources: sources }
}
}
-impl Registry for SourceSet {
+impl<'a> Registry for SourceSet<'a> {
fn query(&mut self, name: &Dependency) -> CargoResult<Vec<Summary>> {
let mut ret = Vec::new();
}
}
-impl Source for SourceSet {
+impl<'a> Source for SourceSet<'a> {
fn update(&mut self) -> CargoResult<()> {
for source in self.sources.mut_iter() {
try!(source.update());
}
}
-pub fn shell(verbose: bool) -> MultiShell {
+pub fn shell(verbose: bool) -> MultiShell<'static> {
let tty = stderr_raw().isatty();
let stderr = box stderr() as Box<Writer>;
pub struct CompileOptions<'a> {
pub update: bool,
pub env: &'a str,
- pub shell: &'a mut MultiShell,
+ pub shell: &'a mut MultiShell<'a>,
pub jobs: Option<uint>,
pub target: Option<&'a str>,
pub dev_deps: bool,
pub rustc_version: String,
pub config: &'b mut Config<'b>,
pub resolve: &'a Resolve,
- pub sources: &'a SourceMap,
+ pub sources: &'a SourceMap<'b>,
pub compilation: Compilation,
env: &'a str,
/* TODO: Refactor GitSource to delegate to a PathSource
*/
-pub struct GitSource<'a, 'b> {
+pub struct GitSource<'a, 'b:'a> {
remote: GitRemote,
reference: GitReference,
db_path: Path,
pub struct Config<'a> {
home_path: Path,
- shell: &'a mut MultiShell,
+ shell: &'a mut MultiShell<'a>,
jobs: uint,
target: Option<String>,
linker: Option<String>,